<?php

namespace App\Admin\Forms;

use App\Admin\Repositories\TodoTask;
use Dcat\Admin\Widgets\Form;
use Illuminate\Support\Facades\Auth;
use Symfony\Component\HttpFoundation\Response;

class QuickCreateTodoForm extends Form
{
    /**
     * Handle the form request.
     *
     * @param array $input
     *
     * @return Response
     */
    public function handle(array $input)
    {
        if (app(TodoTask::class)->quickAdd($input['task_name'], Auth::guard('admin')->id())){
            return $this->success("创建成功");
        }
        return $this->error('创建失败');
    }

    /**
     * Build a form here.
     */
    public function form()
    {
        $this->text('task_name')
            ->maxLength(30, '任务名称不能起过30个字符')
            ->required();
    }

    /**
     * The data of the form.
     *
     * @return array
     */
    public function default()
    {
        return [

        ];
    }
}
